// SDL_gfxPrimitives - Graphics primitives for SDL surfaces
// LGPL (c) A. Schiffler
// Slightly modified to fit into X2D's requirements.

#ifndef _SDL_gfxPrimitives_h
#define _SDL_gfxPrimitives_h

#include <cmath>

#include "SDL.h"

namespace gfx {

// Code from version 2.0.16.

/* ----- Prototypes */

/* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */

  // Pixel
  int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color);

  // Horizontal line
  int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color);

  // Vertical line
  int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color);

  // Line
  int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);

  // AA Line
  int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);

/* Circle */
  int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);

/* AA Circle */
  int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);

/* Filled Circle */
  int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);

/* Ellipse */
  int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);

/* AA Ellipse */
  int aaellipseColor(SDL_Surface * dst, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color);

/* Filled Ellipse */
  int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
    
#define CLOCKWISE

/* Pie */
  int pieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color);

/* Filled Pie */
  int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color);

/* Trigon */
  int trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);

/* AA-Trigon */
  int aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);

/* Filled Trigon */
  int filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);

/* Polygon */
  int polygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);

/* AA-Polygon */
  int aapolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
  int aapolygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/* Filled Polygon */
  int filledPolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
  int texturedPolygon(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy);
/* Bezier */
/* s = number of steps */

  int bezierColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, int s, Uint32 color);

  // Extensions (no surface locking, surface color).
  int xhlineColor(SDL_Surface * dst, Sint16 x1, Sint16 w, Sint16 y, Uint32 color, Uint8 alpha);
  int xvlineColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 h, Uint32 color, Uint8 alpha);
  int xboxColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 w, Sint16 h, Uint32 color, Uint32 alpha);

} // namespace gfx

#endif				/* _SDL_gfxPrimitives_h */
